var Geometry = (function () {

  function Circle(x, y, r)
  {
    this.x = x;
    this.y = y;
    this.r = r;
  }
  
  Circle.MP = 0.5;

  Circle.prototype.midpoint =
    function (c)
    {
      return new Point((this.x+c.x) * Circle.MP, (this.y+c.y) * Circle.MP);    
    }
      
  function intersect(c1, c2)
  {
    var d = Math.sqrt((c2.y-c1.y)*(c2.y-c1.y) + (c2.x-c1.x)*(c2.x-c1.x));
    return (c1.r + c2.r) >= d; 
  }
  
  function Point(x, y)
  {
    // CHANGE TO
    // Circle.call(this, x, y, 0);
    this.x = x;
    this.y = y;
    this.r = 0;
  }
  Point.prototype = Object.create(Circle.prototype);
  
  Point.prototype.toString =
    function ()
    {
      return "{x:" + this.x + ", y:" + this.y + "}";
    }
  
  return {Circle:Circle, Point:Point, intersect:intersect};
})();

function testIntersection(circles)
{
  for (var i = 0; i < circles.length - 1; i++)
  {
    for (var j = i + 1; j < circles.length; j++)
    {
      print(Geometry.intersect(circles[i], circles[j]));
    }
  }
}

///

function client1()
{
  function createCircle(xyr)
  {
    return new Geometry.Circle(xyr[0], xyr[1], xyr[2]);
  }
  var circles = [[10, 10, 50], [60, 40, 30], [100, 100, 10]].map(createCircle);
  testIntersection(circles);
}

client1();

